<!doctype html>
<html lang="en">
   <head>
	  <meta charset="UTF-8">
	  <title>js第二课作业</title>
	  <script>
		 function range(){
			var a = num1.value;
			if(a > 0){
			   num2.value = "大于0";
			}
			else if(a == 0){
			   num2.value = "等于0";
			}
			else{
			   num2.value = "小于0";
			}
		 }

		 function odevity(){
			var b = num3.value;
			if(b%2 ==0 ){
			   num4.value = "偶数";
			}
			else{
			   num4.value = "奇数";
			}
		 }

		 function weight(){
			var c = num5.value;
			var d = num6.value;
			var e = (c - 108) * 2;
			var f = e + 10;
			var g = e - 10;
			if( d >= g && d <= f ){
			   num7.value = "合适";
			}
			else{
			   num7.value = "不合适";
			}
		 }

		 /*function year(){
			var x = num8.value;
			if( x % 400 == 0 || (x % 4 == 0 && !(x % 100 == 0))){
			   num9.value = "是闰年";
			}
			else{
			   num9.value = "不是闰年";
			}*/
		 function year(){
			var x = num8.value;
			if( x % 400 == 0 || (x % 4 == 0 && x % 100)){
			   num9.value = "是闰年";
			}
			else{
			   num9.value = "不是闰年";
			}
		 }

		 document.write("<p>5. 求出1-1/2+1/3-1/4…..1/100的和</p>");
		 var x = 0;
		 /*for(var i=1; i<=100; i++){
			if(i%2){
			   x = x+1/i;
			}
			else{
			   x = x-1/i;
			}
		 }
		 document.write(x);*/
		 var y = 0;
		 for(var i=1;i<100;i=i+2){
			x = x + 1/i;
		 }
		 for(var j=2;j<=100;j=j+2){
			y = y - 1/j;
		 }
		 document.write(x + y);

		 document.write("<p>6. 打印出1000-2000年中所有的闰年，并以每行四个数的形式输出</p>");
		 for(var m=1000;m<=2000;m++){
			if( m % 400 == 0 || m % 4 == 0 && m % 100){
			   document.write(m);
			   document.write("<br/>");
			}
		 }
	  </script>
   </head>
   <body>
   	  <p>1. 判断一个整数，属于哪个范围：大于0；小于0；等于0</p>
   	  <input type="text" id="num1" value=""/>
   	  <input type="button" value="判断整数范围" onclick="range()"/>
   	  <input type="text" id="num2" value="" placeholder="判断结果"/>
   	  <br/>
   	  <br/>
   	  <p>2. 判断一个整数是偶数还是奇数，并输出判断结果</p>
   	  <input type="text" id="num3" value=""/>
   	  <input type="button" value="判断奇偶数" onclick="odevity()"/>
   	  <input type="text" id="num4" value="" placeholder="判断结果"/>
   	  <br/>
   	  <br/>
   	  <p>3. 开发一款软件，根据公式（身高-108）*2=体重，可以有10斤左右的浮动。来观察测试者体重是否合适</p>
   	  <input type="text" id="num5" value="" placeholder="输入你的身高"/>
   	  <input type="text" id="num6" value="" placeholder="输入你的体重"/>
   	  <input type="button" value="判断体重是否标准" onclick="weight()"/>
   	  <input type="text" id="num7" value="" placeholder="判断结果"/>
	  <br/>
	  <br/>
	  <p>4. 计算某一年是否是闰年(与或非的运用) 闰年:能被400整除 或者 能被4整除不能被100整除</p>
	  <input type="text" id="num8" value=""/>
   	  <input type="button" value="判断是否为闰年" onclick="year()"/>
   	  <input type="text" id="num9" value="" placeholder="判断结果"/>
	  <br/>
	  <br/>
	  
   </body>
</html>
